Skip to content

fix(deps): update dependency next-intl to v4 [security]#342

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-next-intl-vulnerability
Open

fix(deps): update dependency next-intl to v4 [security]#342
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/npm-next-intl-vulnerability

Conversation

@renovate
Copy link
Copy Markdown
Contributor

@renovate renovate Bot commented Apr 11, 2026

ℹ️ Note

This PR body was truncated due to platform limits.

This PR contains the following updates:

Package Change Age Confidence
next-intl (source) ^3.14.1^4.0.0 age confidence

next-intl has an open redirect vulnerability

CVE-2026-40299 / GHSA-8f24-v5vv-gm5j

More information

Details

Impact

Applications using the next-intl middleware with localePrefix: 'as-needed' could construct URLs where path handling and the WHATWG URL parser resolved a relative redirect target to another host (e.g. scheme-relative // or control characters stripped by the URL parser), so the middleware could redirect the browser off-site while the user still started from a trusted app URL.

Patches

The problem has been patched, please update to next-intl@4.9.1.

Credits

Many thanks to Joni Liljeblad from Oura for responsibly disclosing the vulnerability and for suggesting the fix.

Severity

  • CVSS Score: 6.9 / 10 (Medium)
  • Vector String: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


next-intl has prototype pollution with experimental.messages.precompile via attacker-controlled translation catalog keys

GHSA-4c35-wcg5-mm9h

More information

Details

Summary

setNestedProperty in packages/next-intl/src/extractor/utils.tsx walks a dotted key path and assigns the final value without blocking the reserved keys __proto__, constructor, or prototype. When the next-intl Next.js plugin is configured with experimental.messages and messages.precompile: true, a JSON translation catalog containing a top‑level __proto__ key causes setNestedProperty(result, '__proto__.isAdmin', compiledMessage) to assign onto Object.prototype, polluting every object in the running build process.

Details

Root cause — packages/next-intl/src/extractor/utils.tsx:13-34:

export function setNestedProperty(
  obj: Record<string, any>,
  keyPath: string,
  value: any
): void {
  const keys = keyPath.split('.');
  let current = obj;

  for (let i = 0; i < keys.length - 1; i++) {
    const key = keys[i];
    if (
      !(key in current) ||
      typeof current[key] !== 'object' ||
      current[key] === null
    ) {
      current[key] = {};
    }
    current = current[key];
  }

  current[keys[keys.length - 1]] = value;
}

The existence check !(key in current) uses the in operator, which walks the prototype chain. For key === '__proto__', '__proto__' in {} is true (it's inherited from Object.prototype) and typeof current['__proto__'] === 'object' (it is Object.prototype). The guard therefore never re-initializes current[key], and current = current['__proto__'] redirects all subsequent writes onto Object.prototype. The final assignment current[keys[keys.length-1]] = value sets Object.prototype[<attacker key>] = <attacker value>.

Build-time data flow:

  1. packages/next-intl/src/plugin/catalog/catalogLoader.tsx:55-83 — the webpack/turbopack loader receives the catalog file source and, if options.messages.precompile is enabled, calls codec.decode(source, {locale}).
  2. packages/next-intl/src/extractor/format/codecs/JSONCodec.tsx:9-18decode runs JSON.parse(source). V8 installs __proto__ as an own data property on the result when the JSON key is literally "__proto__" (bypassing the normal Object.prototype.__proto__ setter that would otherwise reassign the prototype).
  3. JSONCodec.tsx:33-53traverseMessages iterates Object.keys(obj), which for a JSON‑parsed object includes the own __proto__ key. It reads obj.__proto__ (returns the attacker’s nested object, not Object.prototype, because it's an own property), recurses into it, and emits message id __proto__.isAdmin.
  4. catalogLoader.tsx:71precompileMessages(decoded, cache).
  5. catalogLoader.tsx:89-131 — for each message, calls setNestedProperty(result, message.id, compiledMessage). With message.id === '__proto__.isAdmin', setNestedProperty walks into Object.prototype and assigns Object.prototype.isAdmin = compiledMessage.

The same sink is also reachable via JSONCodec.encode (JSONCodec.tsx:20-26) and POCodec (packages/next-intl/src/extractor/format/codecs/POCodec.tsx:87) during extraction, both of which feed attacker-influenced message.id values into setNestedProperty — but those paths require control of source-code identifiers, which is a weaker attack vector than the build-time catalog path above.

After pollution, every subsequent object access during the remainder of the Next.js build pipeline (webpack, turbopack, babel, next-intl’s own logic) inherits the attacker-controlled properties. This is a classic gadget-chain precondition for corrupting build-tool internals and tampering with generated bundles, since many build tools use patterns like if (obj.someFlag) or options[key] ?? default that are sensitive to polluted prototypes.

Trust boundary note: next-intl’s message catalogs are realistically attacker-influenced in practice. Translation files are routinely round-tripped through external TMS systems (Crowdin, Lokalise, Transifex), accepted via community locale PRs, or pulled from third-party translation packages — any of which can carry a crafted __proto__ key unnoticed, since JSON translation diffs are usually merged with minimal scrutiny.

PoC

Prerequisites: a Next.js project using next-intl ≤ 4.9.1 with the Next.js plugin configured:

// next.config.ts
import createNextIntlPlugin from 'next-intl/plugin';

const withNextIntl = createNextIntlPlugin({
  experimental: {
    messages: {
      path: './messages',
      format: 'json',
      locales: 'infer',
      precompile: true
    }
  }
});

export default withNextIntl({});
  1. Drop a malicious catalog at messages/en.json:

    {
      "Greeting": "Hello",
      "__proto__": { "isAdmin": "polluted" }
    }
  2. Run next build (or next dev). The catalogLoader will invoke JSONCodec.decodetraverseMessagesprecompileMessagessetNestedProperty.

  3. Minimal reproduction of the sink itself (verified locally against the v4.9.1 source):

    function setNestedProperty(obj, keyPath, value) {
      const keys = keyPath.split('.');
      let current = obj;
      for (let i = 0; i < keys.length - 1; i++) {
        const key = keys[i];
        if (!(key in current) || typeof current[key] !== 'object' || current[key] === null) {
          current[key] = {};
        }
        current = current[key];
      }
      current[keys[keys.length - 1]] = value;
    }
    
    setNestedProperty({}, '__proto__.isAdmin', 'PWNED');
    console.log(({}).isAdmin); // -> "PWNED"

    Output: PWNED.

  4. Full chain reproduction (also verified):

    const parsed = JSON.parse('{"Greeting":"Hello","__proto__":{"isAdmin":"polluted"}}');
    // traverseMessages emits: [{id:"Greeting",message:"Hello"},{id:"__proto__.isAdmin",message:"polluted"}]
    // precompileMessages then calls setNestedProperty(result, "__proto__.isAdmin", "polluted")
    console.log(({}).isAdmin); // -> "polluted"

    After the loader runs, ({}).isAdmin === 'polluted' for the remainder of the build Node process.

Impact
  • Object.prototype is polluted for the lifetime of the build‑time Node.js process, affecting every object created or inspected thereafter in the Next.js build pipeline (webpack/turbopack loaders, babel plugins, next-intl’s own codecs, user plugins).
  • Classic CWE-1321 gadget-chain precondition: downstream tools that branch on obj.someFlag, options[key] ?? default, if (!config.noX), etc. can be coerced into unintended behavior, including emitting tampered bundles.
  • Realistic delivery vectors include TMS round-trips (Crowdin/Lokalise/Transifex), community locale PRs, and compromised/transitively-installed translation packages — all situations where a JSON catalog diff is routinely accepted without the scrutiny given to code changes.
  • Exploitation requires the user to opt in to the experimental.messages + precompile configuration. Users who do not use the extractor/precompile features are not affected.
Recommended Fix

Reject reserved keys in setNestedProperty and stop using the in operator for the existence check. A minimal patch to packages/next-intl/src/extractor/utils.tsx:

const FORBIDDEN_KEYS = new Set(['__proto__', 'constructor', 'prototype']);

export function setNestedProperty(
  obj: Record<string, any>,
  keyPath: string,
  value: any
): void {
  const keys = keyPath.split('.');
  for (const key of keys) {
    if (FORBIDDEN_KEYS.has(key)) {
      throw new Error(`Invalid message id segment: ${key}`);
    }
  }

  let current = obj;
  for (let i = 0; i < keys.length - 1; i++) {
    const key = keys[i];
    if (
      !Object.prototype.hasOwnProperty.call(current, key) ||
      typeof current[key] !== 'object' ||
      current[key] === null
    ) {
      current[key] = Object.create(null);
    }
    current = current[key];
  }

  current[keys[keys.length - 1]] = value;
}

Additionally:

  • In packages/next-intl/src/extractor/format/codecs/JSONCodec.tsx, make traverseMessages skip reserved keys (or switch to Object.create(null) + Object.hasOwn semantics) so that a malicious catalog is rejected early with a clear error rather than producing __proto__.* message ids.
  • In packages/next-intl/src/plugin/catalog/catalogLoader.tsx, initialize precompileMessages’s result with Object.create(null) as defense in depth, so even if a key slipped through it could not redirect through Object.prototype.

Severity

  • CVSS Score: 4.2 / 10 (Medium)
  • Vector String: CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:L/I:L/A:L

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

amannn/next-intl (next-intl)

v4.9.2

Compare Source

Bug Fixes

v4.9.1

Compare Source

Bug Fixes

v4.9.0

Compare Source

Features

v4.8.4

Compare Source

Bug Fixes

v4.8.3

Compare Source

Bug Fixes

v4.8.2

Compare Source

Bug Fixes

v4.8.1

Compare Source

Bug Fixes

v4.8.0

Compare Source

Features

v4.7.0

Compare Source

Features

v4.6.1

Compare Source

Bug Fixes

v4.6.0

Compare Source

Features
  • Custom formats for useExtracted, consistency fixes for file references, pruning of messages and sorting of keys (#​2155) (c02818e) – by @​amannn

v4.5.8

Compare Source

Bug Fixes

v4.5.7

Compare Source

Bug Fixes

v4.5.6

Compare Source

Bug Fixes

v4.5.5

Compare Source

Bug Fixes

v4.5.4

Compare Source

Bug Fixes

v4.5.3

Compare Source

Bug Fixes

v4.5.2

Compare Source

Bug Fixes

v4.5.1

Compare Source

Bug Fixes

v4.5.0

Compare Source

Features

v4.4.0

Compare Source

Features

v4.3.12

Compare Source

Bug Fixes

v4.3.11

Compare Source

Bug Fixes

v4.3.10

Compare Source

Bug Fixes

v4.3.9

Compare Source

Bug Fixes

v4.3.8

Compare Source

Bug Fixes

v4.3.7

Compare Source

Bug Fixes

v4.3.6

Compare Source

Bug Fixes

v4.3.5

Compare Source

Bug Fixes

v4.3.4

Compare Source

Bug Fixes

v4.3.3

Compare Source

Bug Fixes

v4.3.2

Compare Source

Bug Fixes

v4.3.1

Compare Source

Bug Fixes

v4.3.0

Compare Source

Features

v4.2.0

Compare Source

Features

v4.1.0

Compare Source

Features

v4.0.3

Compare Source

Features

3.0.3 (2023-11-15)

Bug Fixes
  • Don't retrieve defaults for locale, now and timeZone if these options have been provided to NextIntlClientProvider (#​633) (824363a), closes #​631

3.0.2 (2023-11-15)

Bug Fixes
  • Allow usage of getTranslations({namespace}) without TypeScript integration for messages (#​630) (62cf29c), closes #​625

3.0.1 (2023-11-14)

Add provenance statement to published packages.

v4.0.2

Compare Source

Bug Fixes

v4.0.1

Compare Source

Bug Fixes

v4.0.0

Compare Source

See the announcement.

(#​1412) (172656f) – by @​amannn

v3.26.5

Compare Source

Bug Fixes

v3.26.4

Compare Source

Bug Fixes

v3.26.3

Compare Source

Bug Fixes

v3.26.2

Compare Source

Bug Fixes

v3.26.1

Compare Source

Bug Fixes

v3.26.0

Compare Source

Features

v3.25.3

Compare Source

Bug Fixes

v3.25.2

Compare Source

Bug Fixes
  • Handle inconsistency in Next.js when using usePathname with custom prefixes, localePrefix: 'as-needed' and static rendering (#​1573) (20fd0f0) – by @​amannn

v3.25.1

Compare Source

Bug Fixes

v3.25.0

Compare Source

Features

v3.24.0

Compare Source

Features

v3.23.5

Compare Source

Bug Fixes

v3.23.4

Compare Source

Bug Fixes

v3.23.3

Compare Source

Bug Fixes
  • Resolve locale for navigation APIs consistently from i18n/request.ts in react-server like all other APIs do (#​1459) (8c6d5ff) – by @​amannn

v3.23.2

Compare Source

Bug Fixes

v3.23.1

Compare Source

Bug Fixes

v3.23.0

Compare Source

Features

v3.22.0

Compare Source

Features
  • feat: createNavigation (#​1316)
  • feat: Add async requestLocale param to getRequestConfig for Next.js 15 support (#​1383)
  • feat: Add localeCookie option for middleware (#​1414)
  • feat: Add setRequestLocale (#​1437)
Fixes
  • fix: When using domains, handle unknown domains more gracefully (#​1389)
Deprecations
  • Deprecate defaultTranslationValues (#​1411)
  • Deprecate unstable_setRequestLocale (#​1437)

v3.21.1

Compare Source

Bug Fixes
  • Repair package publishing workflow (this release doesn't include any library changes) (ceba9ae) – by @​amannn

v3.20.0

Compare Source

Features

v3.19.5

Compare Source

Bug Fixes

v3.19.4

Compare Source

Bug Fixes

v3.19.3

Compare Source

Bug Fixes

v3.19.2

Compare Source

Bug Fixes

v3.19.1

Compare Source

Bug Fixes

v3.19.0

Compare Source

Features

v3.18.1

Compare Source

Bug Fixes
  • Print warning for inconsistent i18n setup where no locale is read in getRequestConfig and also none is returned (#​1305) (2f0f781) – by @​amannn

v3.18.0

Compare Source

Features

v3.17.6

Compare Source

Bug Fixes

v3.17.5

Compare Source

Bug Fixes
  • Lazy init message formatter for improved tree shaking in case useTranslations is only used in Server Components (#​1279) (9f1725c) – by @​amannn

v3.17.4

Compare Source

Bug Fixes

v3.17.3

Compare Source

Bug Fixes
  • Handle optional catch-all segments in navigation APIs if no value is provided and handle the case if a dynamic value appears multiple times in a pathname (#​1259) (58ef482), closes #​1236 – by @​amannn

v3.17.2

Compare Source

Bug Fixes

v3.17.1

Compare Source

Bug Fixes
  • Apply useMemo for useRouter returned from createLocalizedPathnamesNavigation to keep a stable reference when possible (#​1201) (a1b9a36), closes #​1198 – by @​amannn

v3.17.0

Compare Source

Features

v3.16.0

Compare Source

Features

v3.15.5

Compare Source

Bug Fixes

v3.15.4

Compare Source

Bug Fixes

v3.15.3

Compare Source

Bug Fixes
  • Prefer more specific routes in usePathname when detecting the currently active pathname for localized pathnames (#​1152) (936839e), closes #​1151 – by @​amannn

v3.15.2

Compare Source

Note: Version bump only for package root

v3.15.1

Compare Source

Bug Fixes
  • Remove @formatjs/ecma402-abstract dependency in favor of the automatically bundled one from intl-messageformat ([#​1141](https://redirect.githu

Note

PR body was truncated to here.


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • ""
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate Bot changed the title fix(deps): update dependency next-intl to v4 [security] fix(deps): update dependency next-intl to v4 [security] - autoclosed Apr 27, 2026
@renovate renovate Bot closed this Apr 27, 2026
@renovate renovate Bot deleted the renovate/npm-next-intl-vulnerability branch April 27, 2026 18:55
@renovate renovate Bot changed the title fix(deps): update dependency next-intl to v4 [security] - autoclosed fix(deps): update dependency next-intl to v4 [security] Apr 27, 2026
@renovate renovate Bot reopened this Apr 27, 2026
@renovate renovate Bot force-pushed the renovate/npm-next-intl-vulnerability branch 2 times, most recently from 8d9e701 to 1fd1aeb Compare April 29, 2026 14:07
@renovate renovate Bot force-pushed the renovate/npm-next-intl-vulnerability branch from 1fd1aeb to 78b1f76 Compare May 12, 2026 15:04
@renovate renovate Bot force-pushed the renovate/npm-next-intl-vulnerability branch from 78b1f76 to 66bafdd Compare May 18, 2026 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants